<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Picture extends Backdata_controller{
	var $rule_post=array(
		array(
			'field'=>'title',
			'label'=>'标题',
			'rules'=>'required|max_lenx[255]'),
		array(
			'field'=>'type_id',
	        'rules'=>'intval'),	
		array(
			'field'=>'show',
			'rules'=>'intval'),
		array(
			'field'=>'recommend',
			'rules'=>'intval'),
		array(
			'field'=>'timeline',
			'rules'=>'trim'),
		array(
			'field'=>'field1',
			'rules'=>'trim'),
		array(
			'field'=>'field2',
			'rules'=>'trim'),
		array(
			'field'=>'field3',
			'rules'=>'trim'),
		array(
			'field'=>'field4',
			'rules'=>'trim'),
		array(
			'field'=>'field5',
			'rules'=>'trim'),
		array(
			'field'=>'field6',
			'rules'=>'trim'),
		array(
			'field'=>'field7',
			'rules'=>'trim'),
		array(
			'field'=>'field8',
			'rules'=>'trim'),
		array(
			'field'=>'field9',
			'rules'=>'trim'),
		array(
			'field'=>'field10',
			'rules'=>'trim'),
		array(
			'field'=>'field11',
			'rules'=>'trim'),
		array(
			'field'=>'field12',
			'rules'=>'trim'),
		array(
			'field'=>'content',
			'label'=>'详细内容',
			'rules'=>'required'),
		);
	
	var $search_post=array(
		array(
			'field'=>'title',
			'label'=>'标题',
			'rules'=>'trim'),
		array(
			'field'=>'timeline',
			'rules'=>'trim'),
		array(
			'field'=>'expire',
			'rules'=>'trim'),
	);	
		
	function on_load(){
		$this->load->model('dataset_atom','my_model');
		$this->load->library('category');
		$this->view=$this->table=strtolower(get_class($this));
		$this->category->table_name('admin_act');
		$this->category->block(strtolower(get_class($this)));
		$this->category->type_id($this->uri->segment(3,-1));
		$type_tree=$this->category->type_tree();
		$this->load->vars(array('type_tree'=>$type_tree));
	}

	function on_post(){
		return array('rule'=>$this->rule_post);
	}
	
	function on_put(){
		return array('rule'=>$this->rule_post);
	}
	
	function searchpicture(){
		$type_id=$this->uri->segment(3,-1);
		$this->backview->view("ajax/{$this->view}_searchpicture",get_defined_vars());
	}
	
	function searchpicturepost(){
		$type_id=$this->uri->segment(3,-1);
		$this->load->database();
		$this->load->library('form_validation',$this->search_post);
		if(!$this->form_validation->run()){
			return $this->index();
		}
		$form=$this->form_validation->to_array();
		$form=$this->uri->encode(serialize($form));
		$type_id=$this->uri->segment(3,-1);
		redirect("{$this->title}/index/$type_id/1/null/10/$form");

	}
}